<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserCouponTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_coupon', function (Blueprint $table) {
            $table->increments('id')->comment('用户卡卷ID');
            $table->string('name', 120)->comment('优惠劵名称');
            $table->integer('coupon_id')->unsigned()->comment('卡卷ID');
            $table->integer('user_id')->unsigned()->comment('用户ID');
            $table->string('code',120)->unique()->comment('优惠劵编码');
            $table->decimal('min_price', 10, 2)->default(0)->comment('最小使用金额');
            $table->decimal('max_value', 10, 2)->default(0)->comment('优惠劵金额');
            $table->string('remark', 120)->comment('兑换说明');
            $table->integer('status')->unsigned()->default(1)->comment('使用情况，未使用1，已使用2');
            $table->integer('goods_id')->unsigned()->default(0)->comment('商品ID');
            $table->integer('order_number')->unsigned()->comment('使用的订单号');
            $table->decimal('order_promotion_price', 10, 2)->comment('订单优惠金额');
            $table->integer('scope_type')->unsigned()->default(1)->comment('使用范围类型:1:满减类型,2:赠送类型,3:直接赠送小妖币');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_coupon');
    }
}
